﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><style>/*<![CDATA[*/

table{border: 1px solid gray;}
td{border: 1px dotted gray;}
p{margin: 3px 0 3px 0; padding: 0;}
#ID_Footer{font-size: small; font-style: italic; text-align: right; margin-top: 4em; padding-top: 4px; border-top: 2px solid gray;}

/*]]>*/</style><title>第1章 PHP快速入门</title></head><body>
<div><span class="Apple-style-span" style="font-family: 微软雅黑; line-height: 45px; font-size: large; "><b>&nbsp;</b></span></div><div><span style="font-family: 微软雅黑; font-size: 18pt; font-weight: bold; padding-left: 49pt; line-height: 190%">第</span><span style="font-family: Consolas; font-size: 18pt; font-weight: bold; padding-left: 49pt; line-height: 190%">1</span><span style="font-family: 微软雅黑; font-size: 18pt; font-weight: bold; padding-left: 49pt; line-height: 190%">章 &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: Consolas; font-size: 20pt; font-weight: bold; padding-left: 49pt; line-height: 190%">PHP</span><span style="font-family: 微软雅黑; font-size: 20pt; font-weight: bold; padding-left: 49pt; line-height: 190%">快速入门</span></div>
<div><span style="font-family: 微软雅黑; font-size: 14pt; padding-left: 70pt; line-height: 170%">1.1 &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 宋体; font-size: 16pt; padding-left: 70pt; line-height: 170%">使用场景</span></div>
<div><span style="font-family: Consolas; font-size: 10pt; font-style: italic; color: #2f5496; padding-left: 21pt">&lt;form </span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; font-style: italic; color: #c00000; padding-left: 21pt">action</span><span style="font-family: Consolas; font-size: 10pt; font-style: italic; color: #2f5496; padding-left: 21pt">="</span><span style="font-family: Consolas; font-size: 10pt; font-style: italic; color: #ff0000; padding-left: 21pt">processorder.php</span><span style="font-family: Consolas; font-size: 10pt; font-style: italic; color: #2f5496; padding-left: 21pt">" </span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; font-style: italic; color: #c00000; padding-left: 21pt">method</span><span style="font-family: Consolas; font-size: 10pt; font-style: italic; color: #2f5496; padding-left: 21pt">="post"&gt;...&lt;/form&gt;</span></div>
<div><br></div>
<div>
<ol>
<li><span style="font-family: Consolas; font-size: 10pt">td </span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #ff0000">algin </span><span style="font-family: Consolas; font-size: 10pt">property</span></li>
<li><span style="font-family: Consolas; font-size: 10pt">input type="text" </span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #ff0000">size</span><span style="font-family: Consolas; font-size: 10pt">, </span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #ff0000">maxlength </span><span style="font-family: Consolas; font-size: 10pt">property</span></li>
<li><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #ff0000">name </span><span style="font-family: Consolas; font-size: 10pt">property</span></li></ol>
<div><br></div>
<div><span style="font-family: 微软雅黑; font-size: 14pt; font-weight: bold; padding-left: 70pt; line-height: 170%">1.2 &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 宋体; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">在</span><span style="font-family: Calibri; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">HTML</span><span style="font-family: 宋体; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">中嵌入</span><span style="font-family: Calibri; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">PHP</span></div>
<div><span style="font-family: 宋体; font-size: 10pt; color: #ff0000; padding-left: 42pt">&gt; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: Consolas; font-size: 11pt; color: #ff0000; padding-left: 42pt">PHP</span><span style="font-family: 宋体; font-size: 11pt; color: #ff0000; padding-left: 42pt">标记</span><span style="font-family: 宋体; font-size: 11pt; padding-left: 42pt">，</span><span style="font-family: Consolas; font-size: 11pt; padding-left: 42pt">4</span><span style="font-family: 宋体; font-size: 11pt; padding-left: 42pt">种风格：</span></div>
<div><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; color: #ff0000; padding-left: 39pt; line-height: 160%">* </span><span style="font-family: Consolas; font-size: 10pt; color: #ff0000; padding-left: 39pt; line-height: 160%">XML</span><span style="font-family: 宋体; font-size: 10pt; color: #ff0000; padding-left: 39pt; line-height: 160%">风格：</span><span style="font-family: Consolas; font-size: 10pt; font-style: italic; padding-left: 39pt; line-height: 160%">&lt;? php &nbsp;</span><span style="font-family: Times New Roman; font-size: 10pt; font-style: italic; padding-left: 39pt; line-height: 160%">...</span><span style="font-family: Consolas; font-size: 10pt; font-style: italic; padding-left: 39pt; line-height: 160%">  &nbsp; &nbsp; &nbsp; &nbsp;?&gt; </span><span style="font-family: Consolas; font-size: 10pt; padding-left: 39pt; line-height: 160%">(php5.2.6</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">默认可用</span><span style="font-family: Consolas; font-size: 10pt; padding-left: 39pt; line-height: 160%">)</span></div>
<div><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">* </span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">简短风格：</span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; font-style: italic; color: #c00000; padding-left: 39pt; line-height: 160%">&lt;? &nbsp;</span><span style="font-family: Times New Roman; font-size: 10pt; font-weight: bold; font-style: italic; color: #c00000; padding-left: 39pt; line-height: 160%">...</span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; font-style: italic; color: #c00000; padding-left: 39pt; line-height: 160%">  &nbsp; &nbsp; &nbsp; &nbsp;?&gt; </span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">（在配置文件中启用</span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #ff00ff; padding-left: 39pt; line-height: 160%">short_open_tag</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">，</span><span style="font-family: Consolas; font-size: 10pt; padding-left: 39pt; line-height: 160%">php5.2</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">默认开启）</span></div>
<div><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">* </span><span style="font-family: Consolas; font-size: 10pt; padding-left: 39pt; line-height: 160%">SCRIPT</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">风格：</span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #ff0000; padding-left: 39pt; line-height: 160%">&lt;script language='php'&gt;...&lt;/script&gt;</span><span style="font-family: Consolas; font-size: 10pt; padding-left: 39pt; line-height: 160%"> (php5.2.6</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">默认可以用</span><span style="font-family: Consolas; font-size: 10pt; padding-left: 39pt; line-height: 160%">)</span></div>
<div><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">* </span><span style="font-family: Consolas; font-size: 10pt; padding-left: 39pt; line-height: 160%">ASP</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">风格</span><span style="font-family: Consolas; font-size: 10pt; padding-left: 39pt; line-height: 160%"> </span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; font-style: italic; color: #c00000; padding-left: 39pt; line-height: 160%">&lt;% ... %&gt;</span><span style="font-family: Consolas; font-size: 10pt; padding-left: 39pt; line-height: 160%"> (</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">默认</span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">asp_tags</span><span style="font-family: Consolas; font-size: 10pt; padding-left: 39pt; line-height: 160%"> = Off)</span></div>
<div><br></div>
<div><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; color: #000000; padding-left: 42pt">&gt; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; padding-left: 42pt">PHP</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #000000; padding-left: 42pt">语句</span></div>
<div><span style="font-family: Consolas; font-size: 10pt; font-style: italic; color: #ff0000; padding-left: 21pt; line-height: 160%">echo</span><span style="font-family: Consolas; font-size: 10pt; font-style: italic; color: #ff0000; padding-left: 21pt; line-height: 160%"> </span><span style="font-family: Consolas; font-size: 10pt; font-style: italic; color: #c45911; padding-left: 21pt; line-height: 160%">'&lt;p&gt; Order processed.&lt;/p&gt;';</span></div>
<div><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">* </span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">以</span><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">双引号</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">或</span><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">单引号</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">包围，或以</span><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">函数</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">形式字符串作为参数调用</span><span style="font-family: Times New Roman; font-size: 10pt; padding-left: 39pt; line-height: 160%">.</span></div>
<div><span style="font-family: Times New Roman; font-size: 11pt; padding-left: 39pt; line-height: 160%">* &nbsp;</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; padding-left: 39pt; line-height: 160%">单引号</span><span style="font-family: 宋体; font-size: 11pt; padding-left: 39pt; line-height: 160%">按原样输出，</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; padding-left: 39pt; line-height: 160%">双引号</span><span style="font-family: 宋体; font-size: 11pt; padding-left: 39pt; line-height: 160%">会解析变量及转义字符。</span></div>
<div><br></div>
<div><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; line-height: 170%">3</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; line-height: 170%">种注释</span></div>
<div><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">* </span><span style="font-family: Consolas; font-size: 10pt; color: #ff0000; padding-left: 39pt; line-height: 160%">//</span><span style="font-family: Times New Roman; font-size: 10pt; padding-left: 39pt; line-height: 160%">,</span><span style="font-family: Consolas; font-size: 10pt; padding-left: 39pt; line-height: 160%"> </span><span style="font-family: Consolas; font-size: 10pt; color: #ff0000; padding-left: 39pt; line-height: 160%">/* */</span><span style="font-family: Times New Roman; font-size: 10pt; padding-left: 39pt; line-height: 160%">,</span><span style="font-family: Consolas; font-size: 10pt; padding-left: 39pt; line-height: 160%"> </span><span style="font-family: Consolas; font-size: 10pt; color: #ff0000; padding-left: 39pt; line-height: 160%">#</span></div>
<div><br></div>
<div><span style="font-family: 微软雅黑; font-size: 14pt; font-weight: bold; padding-left: 70pt; line-height: 170%">1.3 &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 宋体; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">添加动态内容</span><span style="font-family: Calibri; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">(p7)</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 160%">连接操作符</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 160%">(.)</span></div>
<div><br></div>
<div><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%"> &nbsp;1.3.1 date()</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">函数</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; color: #ff0000; line-height: 170%">date</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">('H:i, js F Y');</span></div>
<div><br></div>
<div><span style="font-family: 微软雅黑; font-size: 14pt; font-weight: bold; padding-left: 70pt; line-height: 170%">1.4 &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 宋体; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">访问表单变量（</span><span style="font-family: Calibri; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">p9</span><span style="font-family: 宋体; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">）</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">变量均以</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">$</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">符号</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">开始</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%"> &nbsp;1.4.1 </span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">访问表单变量的</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">3</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">种风格</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">简短风格：</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">$tireqty </span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">（默认</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; line-height: 170%">register_globals</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%"> = Off</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">）</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">中等风格：</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">$_POST['tireqty']</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">冗长风格：</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">$HTTP_POST_VARS</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">['tireqty']</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">中等风格的</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">3</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">种数组（超级全局变量）</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">:</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">$_POST</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">, </span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">$_GET</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">, </span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">$_REQUEST</span></div>
<div><br></div>
<div><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%"> &nbsp;1.4.2 </span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">字符串的连接</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">(p11)</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">echo $tireqty</span><span style="font-family: Times New Roman; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">.</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%"> 'tires&lt;br /&gt;'</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; line-height: 170%">;</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; line-height: 170%">双引号和单引号区别</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">：双引号对变量是插值，字符可以用转义符号表示</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">heredoc</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">语法：</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; text-decoration: underline; line-height: 170%">结束标记必须顶头写</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">。</span></div>
<div><br></div>
<div><span style="font-family: 微软雅黑; font-size: 14pt; font-weight: bold; padding-left: 70pt; line-height: 170%">1.5 &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 宋体; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">理解标志符（</span><span style="font-family: Calibri; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">p12</span><span style="font-family: 宋体; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">）</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">区分大小写</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">但</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; text-decoration: underline; line-height: 170%">函数名不区分大小写</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">一个变量名</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; line-height: 170%">可以和函数名相同</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">变量不要求在使用前声明，第一次赋值时，自动创建</span></div>
<div><br></div>
<div><span style="font-family: 微软雅黑; font-size: 14pt; font-weight: bold; padding-left: 70pt; line-height: 170%">1.6 &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 宋体; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">检查变量类型</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">基本数据类型：</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">Integer, Float (or Double), String, Boolean, Array, Object</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">特殊类型：</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">NULL, resource</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">类型转换：</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; background-color: #ffff00; line-height: 170%">(float)</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">$tireqty</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">可变变量</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">：</span></div>
<div><span style="font-family: Consolas; font-size: 10pt; font-style: italic; color: #2f5496; padding-left: 21pt">$varname = 'tireqty';</span></div>
<div><span style="font-family: Consolas; font-size: 10pt; padding-left: 21pt">$$varname = 5;</span></div>
<div><br></div>
<div><span style="font-family: 微软雅黑; font-size: 14pt; font-weight: bold; padding-left: 70pt; line-height: 170%">1.7 &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 宋体; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">声明和使用常量</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; color: #ff0000; line-height: 170%">define</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">('TIREPRICE', 100);</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">引用常量时，前面没有</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">$</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">符号</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">显示</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">php</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">的预定义常量</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">: </span><span style="font-family: Consolas; font-size: 11pt; color: #ff0000; line-height: 170%">phpinfo</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">()</span></div>
<div><br></div>
<div><span style="font-family: 微软雅黑; font-size: 14pt; font-weight: bold; padding-left: 70pt; line-height: 170%">1.8 &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 宋体; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">理解变量作用域</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">6</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">种作用域规则：</span></div>
<div><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">* &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">内置</span><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">超级全局变量</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">：脚本任何地方</span></div>
<div><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">* &nbsp; &nbsp; &nbsp; &nbsp;常量</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">：全局，包括函数内部</span></div>
<div><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">* &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">脚本中声明的变量：全局，函数内部除外</span></div>
<div><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">* &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">函数内部声明的全局变量：名称与外部全局变量一致</span></div>
<div><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">* &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">内部创建并声明的静态变量：仅内部可见，多次执行中保持该值</span></div>
<div><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">* &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">函数内部创建的变量：内部有效</span></div>
<div><br></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">超级全局变量完整列表</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">(p16)</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">，举例</span></div>
<div><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">* &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: Consolas; font-size: 10pt; padding-left: 39pt; line-height: 160%">$</span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #ff0000; padding-left: 39pt; line-height: 160%">GLOBALS</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">，</span><span style="font-family: Consolas; font-size: 10pt; padding-left: 39pt; line-height: 160%"> </span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">所有全局变量数组</span></div>
<div><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">* &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: Consolas; font-size: 10pt; padding-left: 39pt; line-height: 160%">$</span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #ff0000; padding-left: 39pt; line-height: 160%">_SERVER</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">，服务器环境变量数组</span></div>
<div><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">* &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: Consolas; font-size: 10pt; padding-left: 39pt; line-height: 160%">$</span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #ff0000; padding-left: 39pt; line-height: 160%">_GET</span><span style="font-family: Consolas; font-size: 10pt; padding-left: 39pt; line-height: 160%">, $</span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #ff0000; padding-left: 39pt; line-height: 160%">_POST</span></div>
<div><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">* &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">$</span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #ff0000; padding-left: 39pt; line-height: 160%">_COOKIE</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">，</span><span style="font-family: Consolas; font-size: 10pt; padding-left: 39pt; line-height: 160%">cookie</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">变量数组</span></div>
<div><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">* &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: Consolas; font-size: 10pt; padding-left: 39pt; line-height: 160%">$</span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #ff0000; padding-left: 39pt; line-height: 160%">_FILES</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">，与文件上传相关的变量数组</span></div>
<div><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">* &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: Consolas; font-size: 10pt; padding-left: 39pt; line-height: 160%">$</span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #ff0000; padding-left: 39pt; line-height: 160%">_ENV</span><span style="font-family: Times New Roman; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">,</span><span style="font-family: Consolas; font-size: 10pt; padding-left: 39pt; line-height: 160%"> </span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">环境变量数组</span></div>
<div><span style="font-family: 宋体; font-size: 10pt; font-weight: bold; padding-left: 39pt; line-height: 160%">* &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: Consolas; font-size: 10pt; padding-left: 39pt; line-height: 160%">$</span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #ff0000; padding-left: 39pt; line-height: 160%">_REQUEST</span><span style="font-family: 宋体; font-size: 10pt; padding-left: 39pt; line-height: 160%">，所有用户输入的变量数组</span></div>
<div><br></div>
<div><span style="font-family: 微软雅黑; font-size: 14pt; font-weight: bold; padding-left: 70pt; line-height: 170%">1.9 &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 宋体; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">使用操作符</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; color: #000000; line-height: 160%"> &nbsp;1.9.1 </span><span style="font-family: 宋体; font-size: 11pt; color: #000000; line-height: 160%">算术操作符</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">+, -, *, /, %</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%"> &nbsp;1.9.2 </span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">字符串操作符</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">字符串连接操作符</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%"> . </span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">，</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">e.g.</span></div>
<div><span style="font-family: Consolas; font-size: 10pt; font-style: italic; color: #2f5496; padding-left: 21pt">$a = </span><span style="font-family: 宋体; font-size: 10pt; font-style: italic; color: #2f5496; padding-left: 21pt">"</span><span style="font-family: Consolas; font-size: 10pt; font-style: italic; color: #2f5496; padding-left: 21pt">Bob 's ";</span></div>
<div><span style="font-family: Consolas; font-size: 10pt; padding-left: 21pt">$b = "Auto Parts ";</span></div>
<div><span style="font-family: Consolas; font-size: 10pt; padding-left: 21pt">$result = $a</span><span style="font-family: Times New Roman; font-size: 14pt; font-weight: bold; color: #ff0000; padding-left: 21pt">.</span><span style="font-family: Consolas; font-size: 10pt; color: #2f5496; padding-left: 21pt">$b;</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%"> &nbsp;1.9.3 </span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">赋值操作符</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">赋值操作符：</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">=</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">复合赋值操作符：</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">+=, -=, *=, /=, %=, </span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">.=</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">递增递减：</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">++, --</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">引用操作符</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; padding-left: 21pt; line-height: 160%">$b = </span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; padding-left: 21pt; line-height: 160%">&amp;</span><span style="font-family: Consolas; font-size: 11pt; padding-left: 21pt; line-height: 160%">$a;</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; padding-left: 21pt; line-height: 160%">unset</span><span style="font-family: Consolas; font-size: 11pt; padding-left: 21pt; line-height: 160%">($a); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//</span><span style="font-family: 宋体; font-size: 11pt; padding-left: 21pt; line-height: 160%">破坏</span><span style="font-family: Consolas; font-size: 11pt; padding-left: 21pt; line-height: 160%">$a</span><span style="font-family: 宋体; font-size: 11pt; padding-left: 21pt; line-height: 160%">与其值之间的链接</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%"> &nbsp;1.9.4 </span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">比较操作符</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">(p19)</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">返回结果：非</span><span style="font-family: Times New Roman; font-size: 11pt; line-height: 170%">0</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">数值都是</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">true</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">, 0</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">值为</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">false</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">值比较：</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">== </span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">恒等操作符：</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">===</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">，操作数相等并且具有相同的数据类型</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">不等：</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">!=</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">, </span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">&lt;&gt;</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">不恒等：</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">!==</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">其它：</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">&lt;, &gt;, &lt;=, &gt;=</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%"> &nbsp;1.9.5 </span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">逻辑操作符</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">!, &amp;&amp;, ||, </span><span style="font-family: Consolas; font-size: 11pt; color: #ff0000; line-height: 170%">and</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">, </span><span style="font-family: Consolas; font-size: 11pt; color: #ff0000; line-height: 170%">or</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">, xor</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%"> &nbsp;1.9.6 </span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">位操作符</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">&amp;, |, ~, ^, &lt;&lt;, &gt;&gt;</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%"> &nbsp;1.9.7 </span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">其他操作符</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">逗号操作符</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">，</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">，特殊操作符</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">new</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">(初始化类的实例), </span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">-&gt;</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">（访问类成员）</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">三元操作符：</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">?:</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">错误抑制操作符：</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">@</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">执行操作符：反向单引号</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">(</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">``</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">)</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">数组操作符：</span></div>
<div>
<ol>
<li><span style="font-family: Consolas; font-size: 10pt">[] &nbsp; &nbsp; &nbsp; &nbsp;(</span><span style="font-family: 宋体; font-size: 10pt">某些数组上下文中：</span><span style="font-family: Consolas; font-size: 10pt">=&gt;)</span></li>
<li><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #ff0000">+</span><span style="font-family: Consolas; font-size: 10pt">, ==, !=, &lt;&gt;, !==</span></li></ol>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">类型操作符：</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">instanceof</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">， e.g., if( $myobject instanceof sampleClass)</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 160%">Math</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 160%">库</span></div>
<div>
<ol>
<li><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; font-style: italic; color: #ff0000">number_format</span><span style="font-family: Consolas; font-size: 10pt">($totalamount, 2); &nbsp; &nbsp; &nbsp; &nbsp;//</span><span style="font-family: 宋体; font-size: 10pt">两位小数</span></li></ol>
<div><br></div>
<div><span style="font-family: 微软雅黑; font-size: 14pt; font-weight: bold; padding-left: 70pt; line-height: 170%">1.10 &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 宋体; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">优先级和结合性（</span><span style="font-family: Calibri; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">p24</span><span style="font-family: 宋体; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">）</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">优先级表见</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">(p24)</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">print</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%"> </span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">等价与</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">echo</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">，都不是真正的函数，都可以用带有参数的函数形式调用</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">print</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">以函数形式调用时返回值</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">(1)</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">print</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">速度慢于</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">echo</span></div>
<div><br></div>
<div><span style="font-family: 微软雅黑; font-size: 14pt; font-weight: bold; padding-left: 70pt; line-height: 170%">1.11 &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 宋体; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">使用可变函数</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; color: #000000; line-height: 160%"> &nbsp;1.11.1 </span><span style="font-family: 宋体; font-size: 11pt; color: #000000; line-height: 160%">测试和设置变量类型</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">混合数据类型</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">(</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">mixed</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">):</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">被函数用作参数类型，</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; line-height: 170%">伪"混合"</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">，表示可以用任意数据类型。</span></div>
<div>
<ol>
<li><span style="font-family: Consolas; font-size: 10pt">string </span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #ff0000">gettype</span><span style="font-family: Consolas; font-size: 10pt">(</span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #ff0000">mixed </span><span style="font-family: Consolas; font-size: 10pt">var); &nbsp; &nbsp; &nbsp; &nbsp;//</span><span style="font-family: 宋体; font-size: 10pt">返回变量类型的字符串，或</span><span style="font-family: Consolas; font-size: 10pt">"unknown type"</span></li>
<li><span style="font-family: Consolas; font-size: 10pt">bool </span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #ff0000">settype</span><span style="font-family: Consolas; font-size: 10pt">(mixed var, string type); //</span><span style="font-family: 宋体; font-size: 10pt">改变变量类型</span></li></ol>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">其它</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; line-height: 170%">类型测试函数</span></div>
<div>
<ol>
<li><span style="font-family: Consolas; font-size: 10pt">is_array()</span></li>
<li><span style="font-family: Consolas; font-size: 10pt">is_double(), is_float(), is_real()</span><span style="font-family: Times New Roman; font-size: 10pt"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: Consolas; font-size: 10pt">//</span><span style="font-family: 宋体; font-size: 10pt">检查是否浮点数</span></li>
<li><span style="font-family: Consolas; font-size: 10pt">is_long(), is_int(), is_integer() &nbsp; &nbsp; &nbsp; &nbsp;//</span><span style="font-family: 宋体; font-size: 10pt">检查是否整数</span><span style="font-family: Times New Roman; font-size: 10pt"> &nbsp; &nbsp; &nbsp; &nbsp;</span></li>
<li><span style="font-family: Consolas; font-size: 10pt">is_string(), is_bool(), is_object(), is_resource(), is_null()</span></li>
<li><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; font-style: italic; color: #ff0000">is_scalar</span><span style="font-family: Consolas; font-size: 10pt">() &nbsp; &nbsp; &nbsp; &nbsp;//</span><span style="font-family: 宋体; font-size: 10pt">是否标量（即整数、布尔值、字符串或浮点数）</span></li>
<li><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; font-style: italic; color: #ff0000">is_numberic</span><span style="font-family: Consolas; font-size: 10pt">() &nbsp; &nbsp; &nbsp;//</span><span style="font-family: 宋体; font-size: 10pt">是否任何类型的数字或数字字符串</span></li>
<li><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; font-style: italic; color: #ff0000">is_callable</span><span style="font-family: Consolas; font-size: 10pt">() &nbsp; &nbsp; &nbsp;//</span><span style="font-family: 宋体; font-size: 10pt">是否是有效的函数名称</span></li></ol>
<div><br></div>
<div><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%"> &nbsp;1.11.2 </span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">测试变量状态（</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">p26</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">）</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">bool </span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">isset</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">(mixed var) //</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">变量是否存在，可为逗号分隔的变量列表，全设置为</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">true</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">void </span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">unset</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">(mixed var) //</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">销毁变量或变量列表</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">empty</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">() // </span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">变量存在且它的值非空和非</span><span style="font-family: Times New Roman; font-size: 11pt; line-height: 170%">0</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">，返回</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">false(</span><span style="font-family: Consolas; font-size: 11pt; text-decoration: underline; line-height: 170%">echo </span><span style="font-family: 宋体; font-size: 11pt; text-decoration: underline; line-height: 170%">打印为空白</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">)</span></div>
<div><br></div>
<div><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%"> &nbsp;1.11.3 </span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">变量的重解释</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">(p27)</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">转变变量的数据类型</span><span style="font-family: Times New Roman; font-size: 11pt; line-height: 170%">,</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">把变量值转换成适当的类型返回</span></div>
<div><span style="font-family: Consolas; font-size: 10pt; font-style: italic; color: #c45911; padding-left: 21pt; line-height: 160%">int </span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; font-style: italic; color: #ff0000; padding-left: 21pt; line-height: 160%">intval</span><span style="font-family: Consolas; font-size: 10pt; font-style: italic; color: #c45911; padding-left: 21pt; line-height: 160%">(mixed var [, int base]); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//base</span><span style="font-family: 宋体; font-size: 10pt; font-style: italic; color: #c45911; padding-left: 21pt; line-height: 160%">指定基数</span></div>
<div><span style="font-family: Consolas; font-size: 10pt; padding-left: 21pt; line-height: 160%">float </span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #ff0000; padding-left: 21pt; line-height: 160%">floatval</span><span style="font-family: Consolas; font-size: 10pt; color: #c45911; padding-left: 21pt; line-height: 160%">(mixed var);</span></div>
<div><span style="font-family: Consolas; font-size: 10pt; padding-left: 21pt; line-height: 160%">string </span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #ff0000; padding-left: 21pt; line-height: 160%">strval</span><span style="font-family: Consolas; font-size: 10pt; color: #c45911; padding-left: 21pt; line-height: 160%">(mixed var);</span></div>
<div><br></div>
<div><span style="font-family: 微软雅黑; font-size: 14pt; font-weight: bold; padding-left: 70pt; line-height: 170%">1.12 &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 宋体; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">根据条件进行决策</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">条件结构和重复结构</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%"> &nbsp;1.12.1 if else</span></div>
<div><span style="font-family: Consolas; font-size: 10pt; font-style: italic; color: #2f5496; padding-left: 21pt">if(</span><span style="font-family: Times New Roman; font-size: 10pt; font-style: italic; color: #2f5496; padding-left: 21pt">...</span><span style="font-family: Consolas; font-size: 10pt; font-style: italic; color: #2f5496; padding-left: 21pt">){</span><span style="font-family: Times New Roman; font-size: 10pt; font-style: italic; color: #2f5496; padding-left: 21pt">...}</span><span style="font-family: Consolas; font-size: 10pt; font-style: italic; color: #2f5496; padding-left: 21pt"> else {</span><span style="font-family: Times New Roman; font-size: 10pt; font-style: italic; color: #2f5496; padding-left: 21pt">...}</span></div>
<div><span style="font-family: Consolas; font-size: 10pt; padding-left: 21pt">if(...){...} </span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #ff0000; padding-left: 21pt">elseif</span><span style="font-family: Consolas; font-size: 10pt; color: #2f5496; padding-left: 21pt">(...){}</span><span style="font-family: Times New Roman; font-size: 10pt; color: #2f5496; padding-left: 21pt"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: Consolas; font-size: 10pt; color: #2f5496; padding-left: 21pt">// or</span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #2f5496; padding-left: 21pt"> </span><span style="font-family: Consolas; font-size: 10pt; font-weight: bold; color: #ff0000; padding-left: 21pt">else &nbsp; if</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%"> &nbsp;1.12.2 switch</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">在switch语句中，条件值是一个简单的数据类型（</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">整型、字符串或浮点型</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">）</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">若未遇</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">break</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">，会一直往下执行</span></div>
<div><span style="font-family: Consolas; font-size: 10pt; font-style: italic; color: #2f5496; padding-left: 21pt">switch($find){</span></div>
<div><span style="font-family: Consolas; font-size: 10pt; padding-left: 21pt">case "a":</span></div>
<div><span style="font-family: Consolas; font-size: 10pt; padding-left: 21pt"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</span></div>
<div><span style="font-family: Times New Roman; font-size: 10pt; padding-left: 21pt">...</span></div>
<div><span style="font-family: Consolas; font-size: 10pt; padding-left: 21pt">default:</span></div>
<div><span style="font-family: Consolas; font-size: 10pt; padding-left: 21pt"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</span></div>
<div><span style="font-family: Consolas; font-size: 10pt; padding-left: 21pt">}</span></div>
<div><br></div>
<div><br></div>
<div><span style="font-family: 微软雅黑; font-size: 14pt; font-weight: bold; padding-left: 70pt; line-height: 170%">1.13 &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 宋体; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">迭代</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; color: #000000; line-height: 160%"> &nbsp;1.13.1 while</span><span style="font-family: 宋体; font-size: 11pt; color: #000000; line-height: 160%">循环</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">同</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">C</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">语言</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">双引号包围的字符串可以</span><span style="font-family: 宋体; font-size: 11pt; color: #ff0000; line-height: 170%">跨行</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">双引号里的双引号用 </span><span style="font-family: Times New Roman; font-size: 14pt; font-weight: bold; color: #ff0000; line-height: 170%">\ </span><span style="font-family: 宋体; font-size: 11pt; color: #ff0000; line-height: 170%">转义</span></div>
<div><span style="font-family: Times New Roman; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">\</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">n</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">：在双引号里可表示换行</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%"> &nbsp;1.13.2 for</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">和</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">foreach</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">循环</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">(p34)</span></div>
<div><span style="font-family: Consolas; font-size: 10pt; font-style: italic; color: #2f5496; padding-left: 21pt">for (expression1; condition; expression2)</span></div>
<div><span style="font-family: Consolas; font-size: 10pt; padding-left: 21pt"> &nbsp; &nbsp; &nbsp; &nbsp;expression3;</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">动态创建变量</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">：</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">(p35) </span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">name$用来表示name1, name2, name3等类似的表单域。</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">foreach</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">:</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">专门用于数组</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%"> &nbsp;1.13.3 do...while</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #000000; line-height: 160%">循环</span></div>
<div><br></div>
<div><span style="font-family: 微软雅黑; font-size: 14pt; padding-left: 70pt; line-height: 170%">1.14 &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 宋体; font-size: 16pt; padding-left: 70pt; line-height: 170%">从控制结构或脚本中跳出</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; line-height: 160%">break, continue, </span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 160%">exit</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 160%">语句</span><span style="font-family: 宋体; font-size: 11pt; line-height: 160%">（非函数,类似instanceof）</span></div>
<div><br></div>
<div><span style="font-family: 微软雅黑; font-size: 14pt; font-weight: bold; padding-left: 70pt; line-height: 170%">1.15 &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 宋体; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">使用可替换的控制语法结构</span></div>
<div><span style="font-family: Times New Roman; font-size: 11pt; color: #ff0000; line-height: 170%">{</span><span style="font-family: Consolas; font-size: 11pt; color: #ff0000; line-height: 170%"> </span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">可替换为</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">：</span></div>
<div><span style="font-family: Times New Roman; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">}</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%"> </span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">换为新关键字，如 </span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">endif</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">, </span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">endswitch</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">, </span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">endwhile</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">, </span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">endfor</span><span style="font-family: Consolas; font-size: 11pt; line-height: 170%">, </span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">endforeach</span></div>
<div><br></div>
<div><span style="font-family: 微软雅黑; font-size: 14pt; font-weight: bold; padding-left: 70pt; line-height: 170%">1.16 &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 宋体; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%">使用</span><span style="font-family: Calibri; font-size: 16pt; font-weight: bold; padding-left: 70pt; line-height: 170%"> declare</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">用来设置代码块的</span><span style="font-family: 宋体; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">执行指令</span><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">，即后续代码如何运行的规则</span></div>
<div><span style="font-family: 宋体; font-size: 11pt; line-height: 170%">执行指令：</span><span style="font-family: Consolas; font-size: 11pt; font-weight: bold; color: #ff0000; line-height: 170%">tricks</span></div>
<div><span style="font-family: Consolas; font-size: 11pt; line-height: 160%"> &nbsp; &nbsp; &nbsp; &nbsp;tricks=n  &nbsp; &nbsp; &nbsp; &nbsp;//</span><span style="font-family: 宋体; font-size: 11pt; line-height: 160%">每隔</span><span style="font-family: Consolas; font-size: 11pt; line-height: 160%">n</span><span style="font-family: 宋体; font-size: 11pt; line-height: 160%">行代码运行特定的函数,需</span><span style="font-family: 微软雅黑; font-size: 12pt; font-weight: bold; font-style: italic; color: #800000; line-height: 160%">register_tick_function</span><span style="font-family: 微软雅黑; font-size: 12pt; font-style: italic; color: #800000; line-height: 160%">()</span><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 160%">来注册处理函数</span></div>
<div><span style="font-family: Consolas; font-size: 10pt; font-style: italic; color: #2f5496; padding-left: 21pt">declare (directive)</span></div>
<div><span style="font-family: Times New Roman; font-size: 10pt; padding-left: 21pt">{</span></div>
<div><span style="font-family: Times New Roman; font-size: 10pt; padding-left: 21pt"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: Consolas; font-size: 10pt; padding-left: 21pt">//block</span></div>
<div><span style="font-family: Consolas; font-size: 10pt; padding-left: 21pt">}</span></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div></div></div></div></div></div><script type="text/javascript" language="javascript" src="jquery.js"></script><script type="text/javascript" language="javascript" src="itemlink.js"></script></body></html>